<template>
    <div>
        <h2>六、vuex@4 新特性</h2>
        <p @click="$store.commit('increment')">传统方式：{{ $store.state.count }}</p>
        <p @click="add">组合式函数方式 useStore：{{ count }}</p>
    </div>
</template>

<script>
import { useStore } from 'vuex'
import { toRefs } from 'vue'

export default {
    setup() {
        const store = useStore()
        const add = () => store.commit('increment')
        return {
            ...toRefs(store.state),
            add,
        }
    }
}
</script>

<style lang="scss" scoped>
</style>